package com.itheima.blog.admin.controller;


import com.itheima.api.client.dto.CategoryDto;
import com.itheima.blog.admin.entity.Category;
import com.itheima.blog.admin.service.CategoryService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 博客分类表 前端控制器
 * </p>
 *
 * @author cccg
 * @since 2023-07-12
 */
@RestController
@RequestMapping("/category")
@RequiredArgsConstructor
public class CategoryController {
    private final CategoryService categoryService;
    @ApiOperation(value = "feign获取标签列表", notes = "feign获取标签列表", response = String.class)
    @PostMapping("/getCategoryList")
    public List<Category> getCategoryList() {
        return categoryService.getCategoryAllList();
    }

    @PostMapping("/getIdByName")
    public CategoryDto getCategoryByName(@RequestParam String categoryName){
        return categoryService.getCategoryByName(categoryName);
    }
}
